<template>
    <div>
        <!-- 定义-班次设置 -->
        <el-row>
            <el-col :span="24">
                <div class="container">
                    <!-- 功能栏 -->
                    <el-row>
                        <el-col :span="24" class="fun-container">
                            <div class="lf choose-title">线路</div><el-autocomplete v-model="road" placeholder="" size="mini" style="width:150px;" class="lf choose-input" :fetch-suggestions="querySearch"></el-autocomplete>
                            <div class="lf choose-title choose-input to-place">到站</div><el-autocomplete v-model="toPlace" placeholder="" size="mini" style="width:150px;" class="lf choose-input" :fetch-suggestions="querySearchEnd"></el-autocomplete>
                            <div class="lf choose-title to-place">班次号</div><el-input v-model="carNum" placeholder="" size="mini" style="width:150px;" class="lf choose-input"></el-input>
                            <button class="check-btn rf" @click="check"><img src="../../assets/imgs/operation_btn_icon_chongzhi_default.png" alt="" class="btn-img">
                            查询</button>
                            <button class="check-btn rf" @click="reset"><img src="../../assets/imgs/xoperation_btn_icon_saixuan_default.png" alt="" class="btn-img">
                            重置</button>
                        </el-col>
                    </el-row>
                    <!-- 表格菜单栏 -->
                    <el-row>
                        <el-col :span="24" class="table-fun">
                            <img src="../../assets/imgs/operation_icon_shuaxin_default.png" alt="" class="lf"><div class="lf choose-title2 fun-text" @click="refreshTable">刷新</div>
                            <img src="../../assets/imgs/operation_icon_tianjia_default.png" alt="" class="lf"><div class="lf choose-title2 fun-text" @click="changeVisibles('msg','添加班次')">添加</div>
                            <img src="../../assets/imgs/operation_icon_xiugai_default.png" alt="" class="lf"><div class="lf choose-title2 fun-text" @click="showUpdateWin('msg','修改班次')">修改</div>
                            <img src="../../assets/imgs/operation_icon_shanchu_default.png" alt="" class="lf"><div class="lf choose-title2 fun-text" @click="del()">删除</div>
                            <img src="../../assets/imgs/operation_icon_shengcheng_default.png" alt="" class="lf"><div class="lf choose-title2 fun-text" @click="isShowPlans()">生成班次日计划</div>
                            <img src="../../assets/imgs/operation_icon_guoqi_default.png" alt="" class="lf"><div class="lf choose-title2 fun-text" @click="delPrice('','删除过期票价设置')">删除过期票价设置</div>
                        </el-col>
                    </el-row>
                    <!-- 表格栏 -->
                    <el-row>
                        <el-col :span="24">
                            <avue-crud :data="banTable[0].data" :option="banTable[0].option" @current-row-change="rowChange" :page="this.banTable[0].page" @current-change="banTablePage">
                              <template slot-scope="props" slot="expand">
                               <div class="table-fun">
                                <img src="../../assets/imgs/operation_icon_fuzhi_default.png" alt="" class="lf"><div class="lf choose-title fun-text" @click ="showUpdateWin('msg','复制班次')">复制班次</div>
                                <img src="../../assets/imgs/operation_icon_piaojia_default.png" alt="" class="lf"><div class="lf choose-title fun-text" @click ="showUpdateWin('price','票价')">票价</div>
                                <img src="../../assets/imgs/operation_icon_banci_default.png" alt="" class="lf"><div class="lf choose-title fun-text" @click ="showUpdateWin('seat','配客')">配客</div>
                                <img src="../../assets/imgs/operation_icon_mingxi_default.png" alt="" class="lf"><div class="lf choose-title fun-text" @click ="showUpdateWin('class','排班')" >排班</div>
                               </div>
                              </template>
                            </avue-crud>
                        </el-col>
                    </el-row>
                    <!-- 弹窗 -->
                    <pop-dilog :visible = isShow :width = width :height= height @changeVisible = "changeVisibles('msg','复制班次')" :title = tilte  :infolist = currentMsg.name :time = currentMsg.time>
                          <slot>
                          <banci-subTmpe :tabAcitve = activeTags @closeWin = "changeVisibles('msg','复制班次')" @submitUser = mod 
                          :addRoad = currentMsg.line_name 
                          :addClassNum = currentMsg.bus_id 
                          :addCarTime = currentMsg.bus_time
                          :addSeatCount = currentMsg.seat_count
                          :addCarId = currentMsg.bus_id 
                          :addComp = "sss"
                          :addCarType = "ssss"
                          :addSeatType =  currentMsg.addSeatType
                          :ClassType = "2"
                          :beforeSell = currentMsg.presell_day
                          :checkDoor = currentMsg.checkdoor
                          :endStation = "gunga"
                          :startPlace = "ss1"
                          :beiZhu = currentMsg.remark
                          :selctid = currentRow
                          ></banci-subTmpe>
                          </slot>
                    </pop-dilog>
                    <!-- 生成班次日计划 -->
                      <pop-dilog :visible = isShowPlan :width = width2 :height= height2 @changeVisible = isShowPlans title = "生成班次日计划" :infolist = {name:currentMsg.name}>
                          <slot>
                          <banciCreatePlan @isClosed = isShowPlans></banciCreatePlan>
                          </slot>
                    </pop-dilog>
                    <!-- 复制班次详情 -->                    
                     <!-- <pop-dilog :visible = isShow :width = width :height= height @changeVisible = changeVisibles title = "复制班次详细信息" >
                          <slot>
                          <copyClassInfo @isClosed = changeVisibles></copyClassInfo>
                          </slot>
                    </pop-dilog> -->
                    <pop-submit :visible = isDelte :width = width2 :height= height2 @changeVisible = delPrice :title = title @submit ="deleteOverDate()">
                          <p class = "" style = "font-size:19px;margin:30px;">是否确认删除所有班次的过期票价设置？</p>
                    </pop-submit>
                    <!-- 删除班次计划 -->
                    <pop-submit :visible = isDelteClass  :width = width2 :height= height2 @changeVisible = isDelteClassC :title = tilte @submit ="del()">
                          <p class = "" style = "font-size:19px;margin:30px;">删除班次计划</p>
                    </pop-submit>
                       <!-- 复制班次票价定义 -->
                    <pop-submit :visible = isCopyPath  :width = width2 :height= height2 @changeVisible = copyAllPath :title = tilte @submit ="del()">
                          <p class = "" style = "font-size:19px;margin:30px;">本操作将把 <b>[线路: 岐关-广州番禺 班次: PY006]</b> 的票价定义复制到<b>同线路</b>下其他班次，是否确认继续？</p>
                          <el-checkbox style = "margin:20px 30px;" v-model="checkStart">维持目标班次原票价状态</el-checkbox>
                    </pop-submit>
                    <!-- 复制班次详细信息 -->
                    <div class="right-copyAllmodal-win" v-show="rightCopyAll">
                      <div class="closeWin" @click="closeCopy">X</div>
                          <!-- 标题栏 -->
                          <el-row class="add-title">
                              <el-col :span="24">
                                  <img src="../../assets/imgs/operation_bg_biaoti_default.png" alt=""><span class="add-text">复制班次详细信息 [{{currentRow}}][{{currentMsg.bus_date}}][{{currentMsg.bus_time}}]</span>
                              </el-col>
                          </el-row>
                          <el-row class="copy-text">
                            <el-col :span="24">
                              <div>目标班次</div>
                            </el-col>
                          </el-row>
                          <!-- 表单栏 -->
                          <el-row class="copyAll-form">
                            <el-col :span="24">
                              <avue-form ref="form" v-model="copyForm" :option="copyListOption" class="yz-form copy-form"></avue-form>
                              <!-- 按钮 -->
                                <button class="check-btn rf copyAll-btn" @click="docopyCheck">
                                <img src="../../assets/imgs/operation_btn_icon_chaxun_default.png" alt="" class="btn-img">查询</button>
                            </el-col>
                          </el-row>
                          <!-- 表格栏 -->
                          <el-row class="copy-table">
                            <el-col :span="24" class="copy-tableMsg">
                              <avue-crud :data="copyList.data" :option="copyList.option"></avue-crud>
                            </el-col>
                            <div class="cb"></div>
                          </el-row>
                          <!-- 复制信息 -->
                          <el-row class="copy-text">
                            <el-col :span="24">复制信息</el-col>
                          </el-row>
                          <!-- 复选框栏 -->
                          <avue-form ref="form" v-model="copyCheck" :option="copyCheckListOption" class="yz-form"></avue-form>
                          <!-- 按钮 -->
                          <el-row class="start-btn">
                          <el-col :span="24">
                            <button class="check-btn rf" @click="closeCopyDetail">
                            <img src="../../assets/imgs/operation_btn_icon_quxiao_default.png" alt="" class="btn-img">取消</button>
                            <button class="check-btn rf" @click="rCopyDetail"><img src="../../assets/imgs/operation_btn_icon_tijiao_default.png" alt="" class="btn-img">确定</button>
                          </el-col>
                          </el-row>
                    </div>
                    <!-- 批量复制班次 -->
                    <div v-show="piCopy" class="right-piCopymodal-win">
                      <div class="closeWin" @click="piCopy=false">X</div>
                          <!-- 标题栏 -->
                          <el-row class="add-title">
                              <el-col :span="24">
                                  <img src="../../assets/imgs/operation_bg_biaoti_default.png" alt=""><span class="add-text">复制班次详细信息 [{{currentRow}}][{{currentMsg.bus_time}}]</span>
                              </el-col>
                          </el-row>
                          <el-row>
                            <el-col :span="24">
                              <avue-form v-model="piCopyForm" :option="piOption" class="yz-form"></avue-form>
                            </el-col>
                          </el-row>
                          <el-row>
                              <el-col :span="24">
                                <button class="check-btn rf" @click="piCopy=false">
                                  <img src="../../assets/imgs/operation_btn_icon_quxiao_default.png" alt="" class="btn-img">取消</button>
                                  <button class="check-btn rf" @click="doPiCopy"><img src="../../assets/imgs/operation_btn_icon_tijiao_default.png" alt="" class="btn-img">确定</button>
                              </el-col>
                            </el-row>
                    </div>
                    <!-- 生成班次计划 -->
                    <div v-show="createWin" class="right-createmodal-win">
                      <div class="closeWin" @click="piCopy=false">X</div>
                          <!-- 标题栏 -->
                          <el-row class="add-title">
                              <el-col :span="24">
                                  <img src="../../assets/imgs/operation_bg_biaoti_default.png" alt=""><span class="add-text">生成班次日计划</span>
                              </el-col>
                          </el-row>
                          <el-row>
                            <el-col :span="24">
                              <avue-form v-model="createForm" :option="createOption" class="yz-form"></avue-form>
                            </el-col>
                          </el-row>
                          <el-row>
                              <el-col :span="24">
                                <button class="check-btn rf" @click="createWin=false">
                                  <img src="../../assets/imgs/operation_btn_icon_quxiao_default.png" alt="" class="btn-img">取消</button>
                                  <button class="check-btn rf" @click="doCreatePlan"><img src="../../assets/imgs/operation_btn_icon_tijiao_default.png" alt="" class="btn-img">确定</button>
                              </el-col>
                            </el-row>
                    </div>
                    <!-- 右键菜单 -->
                    <!-- 右键菜单 -->
                    <div class="right-menu">
                      <ul>
                        <li>{{currentMsg.line_name}}</li>
                        <li @click ="changeVisibles('msg','修改')">修改</li>
                        <li @click ="del()">删除</li>
                        <li @click ="isDelteClassC('','删除班次计划')">删除班次计划</li>
                        <li @click ="changeVisibles('msg','复制此班次')">复制此班次</li>
                        <li @click="piCopy=true">复制此班次(批量)</li>
                        <li @click="openRightCopy">复制此班次详细信息</li>
                        <li class="rightTwo">复制票价 
                          <span class="el-icon-caret-right rf"></span>
                        </li>
                        <li class="rightThree">生成班次计划 
                          <span class="el-icon-caret-right rf"></span>
                        </li>
                        <li class="rightFour">生成票计划 
                          <span class="el-icon-caret-right rf"></span>
                        </li>
                      </ul>
                      <!-- 二级右击菜单 -->
                        <div class="right-menuII">
                          <div class="rightII-text" @click ="copyAllPath('','复制票价到同线路所有班次')">复制票价到同线路所有班次</div>
                          <div class="rightII-text" @click ="copyAllPath('','复制票价到同线路同车型班次')">复制票价到同线路同车型班次</div>
                        </div>
                      <!-- 三级右击菜单 -->
                        <div class="right-menuIII">
                          <div class="rightII-text right-menuIII1">本班次<span class="el-icon-caret-right rf"></span></div>
                          <div class="rightII-text right-menuIII2">本线路<span class="el-icon-caret-right rf"></span></div>
                        </div>
                      <!-- 3-1级右击菜单 -->
                        <div class="right-menuIII-I">
                          <div class="rightII-text" @click="createWin=true">不更新已有计划</div>
                          <div class="rightII-text" @click="createWin=true">生成并更新已有计划</div>
                        </div>
                      <!-- 3-2级右击菜单 -->
                        <div class="right-menuIII-II">
                          <div class="rightII-text" @click="createWin=true">不更新已有计划</div>
                          <div class="rightII-text" @click="createWin=true">生成并更新已有计划</div>
                        </div>
                      <!-- 四级右击菜单 -->
                        <div class="right-menuIV">
                          <div class="rightII-text right-menuIV1">本班次<span class="el-icon-caret-right rf"></span></div>
                          <div class="rightII-text right-menuIV2">本线路<span class="el-icon-caret-right rf"></span></div>
                        </div>
                        <!-- 4-1级右击菜单 -->
                        <div class="right-menuIV-I">
                          <div class="rightII-text" @click="createWin=true">不更新已有计划</div>
                          <div class="rightII-text" @click="createWin=true">生成并更新已有计划</div>
                        </div>
                      <!-- 4-2级右击菜单 -->
                        <div class="right-menuIV-II">
                          <div class="rightII-text" @click="createWin=true">不更新已有计划</div>
                          <div class="rightII-text" @click="createWin=true">生成并更新已有计划</div>
                        </div>
                  </div>
                </div>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import qs from "qs";
import TableData from "../../components/common/tableData";
import "../../assets/js/mouse.js";
import popDilog from  "../../components/common/popDilog";
import banciSubTmpe from "../../views/banciSubTmpe/banciSubTmpe";
import banciCreatePlan from "../../views/banciSubTmpe/banciCreatePlan";
import copyClassInfo from "../../views/banciSubTmpe/copyClassInfo";
import popSubmit from  "../../components/common/popDilog2";

const DIC={
  openType:[
    {
      label:"当班",
      value:"1"
    },
    {
      label:"全部",
      value:"2"
    },
    {
      label:"按日期",
      value:"3"
    },
  ],
  tongBuSetting:[
    {
      label:"同步",
      value:"1"
    },
  ],
  longS:[
    {
      label:"",
      value:"1"
    }
  ],
  TongS:[
    {
      label:"",
      value:"1"
    }
  ],
  copyCheckList1:[
    {
      label:"座位",
      value:"seat"
    },
    {
      label:"票价",
      value:"price"
    },
    {
      label:"车牌",
      value:"vecho"
    },
    {
      label:"营运单位",
      value:"comp"
    },
    {
      label:"班车车型",
      value:"carStyle"
    },
    {
      label:"班次状态",
      value:"classState"
    },
    {
      label:"班次类型",
      value:"classStyle"
    },
    {
      label:"预售天数",
      value:"sellDay"
    },
    {
      label:"检票门",
      value:"checkDoor"
    },
    
  ],
  copyCheckList2:[
    {
      label:"发车卡位",
      value:"seat"
    },
    {
      label:"是否配套",
      value:"suitable"
    },
    {
      label:"是否启用",
      value:"startable"
    },
    {
      label:"是否加班",
      value:"isAdd"
    },
    {
      label:"允许远程售票",
      value:"sellFar"
    },
    {
      label:"终点站",
      value:"end"
    },
    {
      label:"打印班次时间",
      value:"printTime"
    },
    {
      label:"打印班次号",
      value:"printID"
    },
    {
      label:"打印座位号",
      value:"printSeat"
    },
  ],
  createList1:[
    {
      label:"覆盖已生成的座位表计划",
      value:"recoverTable"
    }
  ],
  createList2:[
    {
      label:"更新已生成的座位表计划",
      value:"updateTable"
    }
  ],
  createList3:[
    {
      label:"生成票计划表",
      value:"createPlan"
    }
  ],
  createList4:[
    {
      label:"覆盖已生成的票价计划",
      value:"recoverPlan"
    }
  ],
};
export default {
  data: function() {
    return {
      tilte:'',
      innerVisible:false,
      activeTags:'msg',
      activeTag: "2-1",
      road: "",
      title:'复制班次',
      toPlace: "",
      carNum: "",
      currentRow:"",
      isShow:false,
      isShowPlan:false,
      isCreate:false,
      isDelte:false,
      isDelteClass:false,
      isCopyPath:false,
      width:"1000px",
      height:"680px",
      width2:'450px',
      height2:'350px',
      banTable: [
        {
          page: {
            pageSizes: [10],
            total: 2,
            currentPage: 1,
            pageSize: 10
          },
          data: [],
          option: {
            page: true,
            stripe: true,
            menu: false,
            expand:true,
            highlightCurrentRow:true,
            align: "center",
            menuAlign: "center",
            column: []
          }
        }
      ],
      getTablePage: {
        page: 1,
        rows: 30
      },
      delID: "1",
      modList: {
        seat_define_str: "test",
        "busDefine.seat_layout": "test2",
        "busDefine.line_id": "test3",
        lineName: "test4",
        "busDefine.bus_id": "test5",
        from_busdid: "test6",
        "busDefine.bus_time": "test7",
        "busDefine.all_seat": "test8",
        "busDefine.customer_id": "test9",
        "busDefine.vehi_type_id": "test10",
        "busDefine.seat_type": "test11",
        "busDefine.status_id": "test12",
        "busDefine.start_date": "test13",    
        "busDefine.end_date": "test14",
        "busDefine.presell_day": "test15"
      },
      pageSize: 1,
      pageNum: 1,
      totalPage: 0,
      roadList:[],
      endList:[],
      checkRoadID:"",
      checkEndID:"",
      addWin:false,
      modTitle:"添加班次",
      addRoad:"",
      addClassDate:"",
      addClassDateTo:"",
      addClassNum:"",
      addCarTime:"",
      addSeatCount:"",
      addCarId:"",
      addComp:"",
      addCarType:"",
      addCompII:"",
      seatTypeList:[],
      classTypeList:[],
      carList:[],
      beforeSell:"",
      checkDoor:"",
      endStation:"",
      startPlace:"",
      beiZhu:"",
      addFunTab:"msg",
      modCurrentRow:"",
      peiKeMsg:[],
      peiKeList:[],
      addCompList:[],
      peiKeSta:"",
      ClassType:"",
      addSeatType:"",
      seatShow:false,
      checkStart:false,
      checkPei:false,
      checkAddClass:false,
      checkAllow:false,
      checkCarTime:false,
      checkPintSeat:false,
      checkClassNum:false,
      seatDetailList:{    
        data:[],
        option:{
          menu:false,
          column:[
            {
              label:"座号",
              prop:"seat_id"
            },
            {
              label:"状态",
              prop:"status_cn"
            },
            {
              label:"工号",
              prop:"order_no"
            },
            {
              label:"操作时间",
              prop:"check_time"
            },
            {
              label:"票号",
              prop:"billno"
            },
            {
              label:"票型",
              prop:"tks_type"
            },
            {
              label:"购票渠道",
              prop:"test"
            },
            {
              label:"订单时间",
              prop:"order_time"
            },
          ]
        }
      },
      currentMsg:{},
      rightCopyAll:false,
      copyForm:{},
      copyListOption:{
          column:[
            {
              label:"班次日期",
              prop:"BanCidate",
              type:"daterange",
              span:10
            },
            {
              label:"班次号",
              prop:"BCNum",
              span:5
            },
          ]
      },
      copyList:{
        data:[],
        option:{
          menu:false,
          index:true,
          selection:true,
          page:false,
          column:[
            {
              label:"班次号",
              prop:"bus_id"
            },
            {
              label:"班次日期",
              prop:"bus_date"
            },
            {
              label:"发班时间",
              prop:"bus_time"
            },
            {
              label:"班次类型",
              prop:"type"
            },
            {
              label:"状态",
              prop:"status_id"
            },
            {
              label:"总座数",
              prop:"all_seat"
            },
          ]
        }
      },
      copyCheck:{},
      copyCheckListOption:{
        dicData:DIC,
        column:[
          {
            label: "",
            prop: "ccl1",
            span: 24,
            type: "checkbox",
            dicData: 'copyCheckList1',
          },
          {
            label: "",
            prop: "ccl2",
            span: 24,
            type: "checkbox",
            dicData: 'copyCheckList2',
          },
        ]
      },
      piCopy:false,
      piCopyForm:{},
      piOption:{
        column:[
          {
            label:"班次号",
            prop:"startNum",
            span:15,
            tip:"注:往后递增"
          },
          {
            label:"复制数量",
            prop:"copyCount",
            span:15
          },
          {
            label:"时间分隔",
            prop:"time",
            span:15
          },
        ]
      },
      createWin:false,
      createForm:{},
      createOption:{
        dicData:DIC,
        column:[
          {
            label:"",
            span:24,
            type:"checkbox",
            prop:"recoverTable",
            dicData: 'createList1'
          },
          {
            label:"",
            span:24,
            type:"checkbox",
            prop:"update",
            dicData: 'createList2'
          },
          {
            label:"",
            span:24,
            type:"checkbox",
            prop:"createPlan",
            dicData: 'createList3'
          },
          {
            label:"",
            span:24,
            type:"checkbox",
            prop:"recoverPlan",
            dicData: 'createList4'
          },
        ]
      }
    };
  },
  methods: {
    submitInfos(){
      
    },
    banTablePage(val){
      this.banTable[0].page.currentPage=val;
      this.getBanList();
      // console.log(val)
    },
     changeVisibles(name,title){
      this.isShow = !this.isShow;
      title === '添加班次' ? this.currentMsg = {} : title;
      this.activeTags = `${name}`;
      this.tilte = title;
     },
     isShowPlans(){
       this.isShowPlan = !this.isShowPlan;
     },
     /* 过期票价 */
     delPrice(name,title){
       this.isDelte = !this.isDelte;
       this.tilte = title;
     },
     /*   */
     isDelteClassC(name = '', title){
       this.isDelteClass = !this.isDelteClass;
        this.tilte = title;
     },
     copyAllPath(name = '',title){
       this.isCopyPath = !this.isCopyPath;
       this.tilte = title;
     },
        getBanList()  {
      this.banTable[0].data=[];
      this.postRequest("/sch/bus/define/list",{
        rows:"10",
        page:this.banTable[0].page.currentPage
      })
        .then(data => {
          console.log(data);
          this.banTable[0].page.total = data.data.totalRow;
          this.banTable[0].page.currentPage = data.data.pageNumber;
          for (var [index,d] of data.data.list.entries()) {
            this.banTable[0].data.push({
              name:'XF' + index,
              time:'09:10',
              id:d.id,
              bus_time:d.bus_time,
              line_name: d.line_name,
              bus_id: d.bus_id,
              bus_date: d.bus_date,
              type: d.type,
              customer_name: d.customer_name,
              all_seat: d.all_seat,
              can_sale_count: d.can_sale_count,
              salecount: d.salecount,
              checkdoor: d.checkdoor,
              end_seat: d.end_seat,
              kawei: d.kawei,
              seat_type: d.seat_type,
              begin_seat:d.begin_seat,
              vehi_no:d.vehi_no,
              start_date:d.start_dated,
              seat_count:d.seat_count,
              addSeatType:d.addSeatType,
              presell_day:d.presell_day,
              remark:d.dremark
            });
          }
        });
    },
    refreshTable() {
      (this.banTable[0].data = []), this.getBanList();
    },
    add() {
      this.addWin=true;
    },
    submit(){
       this.$http
        .post("/sch/bus/define/add")
        .then(data => {
          this.$message.error(data.data[1]);
        });
        
    },
    del() {
      this.$http
        .post(
          "/sch/bus/define/del",
          qs.stringify({
            id:this.currentRow
          })
        )
        .then(data => {
          if (data.data[0] == 0) {
            this.$message({
              message: data.data[1],
              type: "success"
            });
            this.isDelteClass = false;
          } else {
            this.$message.error(data.data[1]);
          }
        });
    },
    deleteOverDate() {
      this.$http
        .post(
          "/sch/bus/define/price/delOutdates",qs.stringify({
            bus_define_id:this.currentRow
          })
        )
        .then(data => {
          this.$message(data.data[1]);
          this.refreshTable();
        });
        this.isDelte = false;
    },
    mod() {
      this.$http
        .post(
          "/sch/bus/define/update",
          qs.stringify(this.modList)
        )
        .then(data => {
          if (data.data[0] == 0) {
            this.$message({
              message: data.data[1],
              type: "success"
            });
          } else {
            this.$message.error(data.data[1]);
          }
        });
    },
    tableCreate() {
      this.banTable[0].option.column.push(
        {
          label: "线路",
          prop: "line_name"
        },
        {
          label: "班次号",
          prop: ""
        },
        {
          label: "时间",
          prop: "bus_date"
        },
        {
          label: "类型",
          prop: "type"
        },
        {
          label: "状态",
          prop: "customer_name"
        },
        {
          label: "总座位",
          prop: "all_seat"
        },
        {
          label: "可售",
          prop: "can_sale_count"
        },
        {
          label: "计划车牌",
          prop: "bus_id"
        },
        {
          label: "共售",
          prop: "salecount"
        },
        {
          label: "检票口",
          prop: "checkdoor"
        },
        {
          label: "余座",
          prop: "end_seat"
        },
        {
          label: "卡位",
          prop: "kawei"
        },
        {
          label: "座位类型",
          prop: "seat_type"
        },
        {
          label: "营运单位",
          prop: "state"
        }
      );
    },
    reset() {
      this.road="",
      this.carNum="",
      this.getBanList();
    },
    check() {
      var that = this;
      this.banTable[0].data=[];
      this
        .postRequest(
          "/sch/bus/define/list",{
            filterRules:JSON.stringify(
              [
                { field: "line_code", op: "eq", value: that.checkRoadID },
                { field: "bus_id", op: "eq", value: that.carNum },
                { field: "bus_define_price.st_id", op: "eq", value: that.toPlace }
              ]
            ),
            rows:this.banTable.page.currentPage,
            page:10
          }
        )
        .then(data => {
          // console.log(data);
          this.pageSize = data.data.pageSize;
          this.pageNum = data.data.pageNumber;
          this.totalPage = data.data.totalPage;
          for (var d of data.data.list) {
            this.banTable[0].data.push({
              line_name: d.line_name,
              bus_id: d.bus_id,
              bus_date: d.bus_date,
              type: d.type,
              customer_name: d.customer_name,
              all_seat: d.all_seat,
              can_sale_count: d.can_sale_count,
              bus_id: d.bus_id,
              salecount: d.salecount,
              checkdoor: d.checkdoor,
              end_seat: d.end_seat,
              kawei: d.kawei,
              seat_type: d.seat_type,
              customer_name: d.customer_name
            });

          }
        });
    },
    rowChange(val){
      console.log(val);
      this.currentRow=val.id;
      this.currentMsg.line_name=val.line_name;
      this.currentMsg.bus_id=val.bus_id;
      this.currentMsg.bus_time=val.bus_time;
      this.currentMsg.bus_date=val.bus_date;
      this.currentMsg.end_seat=val.end_seat;
      this.currentMsg.status_id=val.status_id;
      this.currentMsg.vehi_no=val.vehi_no;
      this.currentMsg.checkdoor=val.checkdoor;
      this.currentMsg.kawei=val.kawei;
      this.currentMsg.org_name = val.org_name;
      this.currentMsg.addSeatType = val.addSeatType;
      this.currentMsg.remark = val.remark
      this.currentMsg.presell_day = val.presell_day;
      this.currentMsg.seat_count = val.seat_count
      this.currentMsg.name  = val.name;
      this.currentMsg.time = val.time;
      // this.$http.get("/sch/bus/define/getViaStation?bus_define_id=4084="+val.id).then(data=>{
      //   this.peiKeMsg=[];
      //   for(var item of data.data){
      //     this.peiKeMsg.push({
      //       idx:item.idx,
      //       org_name:item.org_name,
      //       bus_id:item.bus_id,
      //       bus_time:item.bus_time
      //     });
      //   }
      // })
    },
    createPlan(){
      this.$http.post("/sch/bus/define/makeplan?overrideSeatLayout=on&updateExistsBusPlan=on&makePricePlan=on&updateExistsPricePlan=on").then(data=>{
         if (data.data[0] == 0) {
            this.$message({
              message: data.data[1],
              type: "success"
            });
          } else {
            this.$message.error(data.data[1]);
          }
      });
    },
    loadRoad(){
      this.$http.post("/sch/data/line/listWithSpell").then(data=>{
        // console.log(data);
        for(var item of data.data){
          this.roadList.push({
            value:item.name,
            id:item.id
          });
        }
      });
    },
    loadEnd(){
      this.$http.post("/sch/data/station/listWithSpell").then(data=>{
        for(var item of data.data){
          this.endList.push({
            value:item.name,
            id:item.id
          });
        }
      });
    },
    querySearch(queryString, cb) {
        var roadlist = this.roadList;
        var results = queryString ? roadlist.filter(this.createFilter(queryString)) : roadlist;
        // 调用 callback 返回建议列表的数据
        cb(results);
    },
    createFilter(queryString) {
      return (roadlist) => {
        return (roadlist.value);
      }
    },
    querySearchEnd(queryString, cb) {
        var endlist = this.endList;
        var results = queryString ? endlist.filter(this.createFilter(queryString)) : endlist;
        // 调用 callback 返回建议列表的数据
        cb(results);
    },
    redClass() {
      this.addWin = false;
      this.addRoad="";
      this.addClassNum="";
      this.addCarTime="";
      this.addSeatCount="";
      this.addCarId="";
      this.startPlace="";
      this.addFunTab="msg"
    },
    getCarList(){
      this.$http.post("/sch/const/bus_vehicle_type/listWithSpell").then(data=>{
        for(var item of data.data){
          this.carList.push({
            value:item.id,
            label:item.name
          });
        }
      })
    },
    TicAdd(){
      this.$http.post("/sch/bus/plan/price/detail?_=1535273667272").then(data=>{
        // console.log(data);
      });
    },
    TicDel(){
      if(this.currentRow!=""){
        this.$http.get("/sch/bus/plan/price/del?id="+this.modCurrentRow).then(data=>{
            if(data.data[0]=="0"){
              this.$message({
              message: data.data[1],
              type: 'success'
              });
              this.modCurrentRow="";
            }else{
              this.$message.error(data.data[1]);
            }
        })
      }else{
        this.$message.error("请选择一条记录");
      }
    },
     TicUpdate(){
      this.$http.get("/sch/bus/plan/price/copyToSameLine?bus_plan_id="+this.currentRow+"&to_all_days=false&keep_status=1").then(data=>{
        if(data.data[0]=="0"){
              this.$message({
              message: data.data[1],
              type: 'success'
              });
              this.modCurrentRow="";
            }else{
              this.$message.error("更新失败！请检查");
            }
      });
    },
    TicTongbu(){
      this.$http.get("/sch/bus/plan/copyViaStationSyncConfig?bus_plan_id="+this.currentRow+"&all_days=0").then(data=>{
        if(data.data[0]=="0"){
              this.$message({
              message: data.data[1],
              type: 'success'
              });
              this.modCurrentRow="";
            }else{
              this.$message.error("更新失败！请检查");
            }
      })
    },
    addClass() {
      this.addWin = true;
      this.modTitle="添加班次"
      this.getSeatTypeList();
      this.getClassTypeList();
      this.getAddCompList();
      this.getChooseItem();
      this.getModList();
      this.getCarList();
    },
    deleteClass() {
      this.$http
        .post("/sch/bus/plan/price/del?id="+this.currentRow)
        .then(data => {
          console.log(data);
          if (data.data[0] == -1) {
            this.$message.error("删除失败！");
          } else {
            this.$message({
              message: data.data[1],
              type: "success"
            });
          }
        });
    },
    showUpdateWin(name,title){
      this.modTitle="修改班次";
      if(this.currentRow==""){
        this.$message.error('请选择一条记录');
      }else{
         this.isShow = !this.isShow;
      // console.dir(name);
        this.activeTags = `${name}`;
        this.tilte = title;
        this.addWin=true;
        this.addRoad=this.currentMsg.line_name;
        this.addClassNum=this.currentMsg.status_id;
        this.addCarTime=this.currentMsg.bus_date;
        this.addSeatCount=this.currentMsg.end_seat;
        this.addCarId=this.currentMsg.vehi_no;
        this.startPlace=this.currentMsg.kawei;
      }
    },
        getClassTypeList(){
      this.$http.post("/sch/data/common/busstatus").then(data=>{
        for(var item of data.data){
          this.classTypeList.push({
            value:item.key,
            label:item.value
          });
        }
      });
    },
    getAddCompList(){
      this.$http.post("/sch/data/common/bustype").then(data=>{
        for(var item of data.data){
          this.addCompList.push({
            value:item.value,
            label:item.key
          });
        }
      });
    },
    getChooseItem(){
      this.$http.post("/common/constant/getYesOrNo").then(data=>{
        for(var item of data.data){
          this.chooseItem.push({
            value:item.value,
            label:item.key
          });
        }
      })
    },
    getModList(){
      this.$http.post("/sch/bus/plan/price/list").then(data=>{
        for(var item of data.data.list){
          this.modList.data.push({
            st_name:item.st_name,
            type_1:item.type_1,
            type_2:item.type_2,
            max_price:item.max_price,
            surcharges:item.surcharges
          });
        }
      })
    },
    TicTableMsg(){
      this.modTitle="修改班次";
      if(this.currentRow==""){
        this.$message.error('请选择一条记录');
      }else{
        this.addWin=true;
        this.addRoad=this.currentMsg.line_name;
        this.addClassNum=this.currentMsg.status_id;
        this.addCarTime=this.currentMsg.bus_date;
        this.addSeatCount=this.currentMsg.end_seat;
        this.addCarId=this.currentMsg.vehi_no;
        this.startPlace=this.currentMsg.kawei;
        this.addFunTab="price";
      }
    },
    peiKeTableMsg(){
      this.modTitle="修改班次";
      if(this.currentRow==""){
        this.$message.error('请选择一条记录');
      }else{
        this.addWin=true;
        this.addRoad=this.currentMsg.line_name;
        this.addClassNum=this.currentMsg.status_id;
        this.addCarTime=this.currentMsg.bus_date;
        this.addSeatCount=this.currentMsg.end_seat;
        this.addCarId=this.currentMsg.vehi_no;
        this.startPlace=this.currentMsg.kawei;
        this.addFunTab="seat";
      }
    },
    copyClass(){
      this.modTitle="复制班次";
      if(this.currentRow==""){
        this.$message.error('请选择一条记录');
      }else{
        this.addWin=true;
        this.addRoad=this.currentMsg.line_name;
        this.addClassNum=this.currentMsg.status_id;
        this.addCarTime=this.currentMsg.bus_date;
        this.addSeatCount=this.currentMsg.end_seat;
        this.addCarId=this.currentMsg.vehi_no;
        this.startPlace=this.currentMsg.kawei;
      }
    },
    getSeatTypeList(){
      this.$http.post("/sch/data/common/busseattype").then(data=>{
        for(var item of data.data){
          this.seatTypeList.push({
            value:item.value,
            label:item.key
          });
        }
      })
    },
     toPlaceII(){
      if(this.toPlace==""){
        this.checkEndID="";
      }else{
        for(var item of this.endList){
          if(this.toPlace==item.value){
            this.checkEndID=item.id
          }
        }
      }
    },
     getModList(){
      this.$http.post("/sch/bus/plan/price/list").then(data=>{
        for(var item of data.data.list){
          this.modList.data.push({
            st_name:item.st_name,
            type_1:item.type_1,
            type_2:item.type_2,
            max_price:item.max_price,
            surcharges:item.surcharges
          });
        }
      })
    },
    getCarList(){
      this.$http.post("/sch/const/bus_vehicle_type/listWithSpell").then(data=>{
        for(var item of data.data){
          this.carList.push({
            value:item.id,
            label:item.name
          });
        }
      })
    },
    getSeatDetailList(){
      var that=this;
      this.seatDetailList=[];
      this.$http.post("/sch/bus/plan/seat/list",qs.stringify({bus_plan_id:this.currentRow})).then(data=>{
        for(var item of data.data){
          that.seatDetailList.data.push({
            seat_id:item.seat_id,
            status_cn:item.status_cn,
            order_no:item.order_no,
            check_time:item.check_time,
            billno:item.billno,
            tks_type:item.tks_type,
            order_time:item.order_time
          });
        }
      });
      // console.log(that.seatTypeList)
    },
    redSeat(){
      this.seatShow=false;
    },
    showSeatDetail(){
      this.seatShow=true;
      this.getSeatDetailList();
    },
    tablerowChange(){},
    modrowChange(val){
      this.modCurrentRow=val.id;
    },
    openRightCopy(){
      this.rightCopyAll=true;
    },
    closeCopy(){
      this.rightCopyAll=false;
    },
    docopyCheck(){
      this.getcopyList();
    },
    getcopyList(){
      this.postRequest("/sch/bus/plan/copylist",{
        bus_plan_id:this.currentRow,
        be_busdate:this.dateToString(this.copyForm.BanCidate[0]),
        ed_busdate:this.dateToString(this.copyForm.BanCidate[1]),
        line_id:this.currentMsg.line_id
      }).then(data=>{
        this.copyList.data=data.data.list;
      })
    },
    closeCopyDetail(){
      this.rightCopyAll=false;
    },
    rCopyDetail(){
      this.postRequest("/sch/bus/plan/doCopybusInfo",{
        bus_plan_id:this.currentRow,
        // copy_seat:this.copyCheck.copyCheckList1[0]?"on":"off",
        // copy_price:this.copyCheck.copyCheckList1[1]?"on":"off",
        // copy_vehi_no:this.copyCheck.copyCheckList1[2]?"on":"off",
        // copy_customer:this.copyCheck.copyCheckList1[3]?"on":"off",
        // copy_vehi_type:this.copyCheck.copyCheckList1[4]?"on":"off",
        // copy_status:this.copyCheck.copyCheckList1[5]?"on":"off",
        // copy_type:this.copyCheck.copyCheckList1[6]?"on":"off",
        // copy_presell:this.copyCheck.copyCheckList1[7]?"on":"off",
        // copy_checkdoor:this.copyCheck.copyCheckList1[8]?"on":"off",
        // copy_kawei:this.copyCheck.copyCheckList2[0]?"on":"off",
        // copy_is_mix:this.copyCheck.copyCheckList2[1]?"on":"off",
        // copy_is_valid:this.copyCheck.copyCheckList2[2]?"on":"off",
        // copy_is_ot:this.copyCheck.copyCheckList2[3]?"on":"off",
        // copy_is_remote:this.copyCheck.copyCheckList2[4]?"on":"off",
        // copy_end_station:this.copyCheck.copyCheckList2[5]?"on":"off",
        // copy_prn_time:this.copyCheck.copyCheckList2[6]?"on":"off",
        // copy_prn_busid:this.copyCheck.copyCheckList2[7]?"on":"off",
        // copy_prn_seat:this.copyCheck.copyCheckList2[8]?"on":"off",
        bus_plan_ids:this.currentRow
      }).then(data=>{
        if(data.data[0]==0){
          this.$message({
            message: data.data[1],
            type: 'success'
          });
          this.closeCopyDetail();
        }else{
          this.$message.error(data.data[1]);
        }
      })
    },
    doPiCopy(){
      this.piCopyForm.startNum;
      this.postRequest("/sch/bus/define/nextbusid",{
        be_bus_id:this.piCopyForm.startNum
      }).then(data=>{
        if(data.data[0]==0){
            this.$message({
            showClose: true,
            message: '复制成功',
            type: 'success'
          });
        }else{
          this.$message.error('复制失败!');
        }
      })
    },
    doCreatePlan(){
      this.postRequest("/sch/bus/define/makeplan",{
        overrideSeatLayout:this.createForm.recoverTable[0]?"on":"off",
        updateExistsBusPlan	:this.createForm.update[0]?"on":"off",
        makePricePlan:this.createForm.createPlan[0]?"on":"off",
        updateExistsPricePlan:this.createForm.recoverPlan[0]?"on":"off",
      }).then(data=>{
        if(data.data[0]==0){
              this.$message({
              showClose: true,
              message: data.data[1],
              type: 'success'
            });
          }else{
          this.$message.error('生成失败!');
          }
      });
    }
  },
  computed: {},
  components: { TableData,popDilog,banciSubTmpe,banciCreatePlan,copyClassInfo,popSubmit},
  watch: {
    road(){
      if(this.road==""){
        this.checkRoadID="";
      }else{
        for(var item of this.roadList){
          if(this.road==item.value){
            this.checkRoadID=item.id
          }
        }
      }
    },
   
  },
  created(){
    
  },
  mounted() {
    this.$emit("sendActive", this.activeTag);
    this.tableCreate();
    this.getBanList();
    this.loadRoad();
    this.loadEnd();
    // 二级右键窗口
    $(".rightTwo,.right-menuII").hover(function(){
      $(".right-menuII").show();
    },function(){
      $(".right-menuII").hide();
    });
    // 三级右键窗口
    $(".rightThree,.right-menuIII,.right-menuIII-I,.right-menuIII-II").hover(function(){
      $(".right-menuIII").show();
    },function(){
      $(".right-menuIII").hide();
    });
    // 3-1级右键窗口
    $(".right-menuIII1,.right-menuIII-I").hover(function(){
      $(".right-menuIII-I").show();
    },function(){
      $(".right-menuIII-I").hide();
    });
    // 3-2级右键窗口
    $(".right-menuIII2,.right-menuIII-II").hover(function(){
      $(".right-menuIII-II").show();
    },function(){
      $(".right-menuIII-II").hide();
    });
    // 四级右键窗口
    $(".rightFour,.right-menuIV,.right-menuIV-I,.right-menuIV-II").hover(function(){
      $(".right-menuIV").show();
    },function(){
      $(".right-menuIV").hide();
    });
    // 4-1级右键窗口
    $(".right-menuIV1,.right-menuIV-I").hover(function(){
      $(".right-menuIV-I").show();
    },function(){
      $(".right-menuIV-I").hide();
    });
    // 4-2级右键窗口
    $(".right-menuIV2,.right-menuIV-II").hover(function(){
      $(".right-menuIV-II").show();
    },function(){
      $(".right-menuIV-II").hide();
    });
  }
};
</script>
<style scoped src="../../assets/css/service/banCiSetting.css">
</style>